home *** CD-ROM | disk | FTP | other *** search
- Variable tracing in WavesWorld is a complex subject, and not fully
- debugged yet. This riff is an attempt to clear away some of the
- cobwebs in my mind, and hopefully kill the bugs.
-
- When a WWTCLInterp starts up, it doesn't have any variables being
- traced. When a WWInterp starts up, it adds a new command called
- "setReadOnly" which will automatically set up a write trace on such
- variables to give an error msg if an attempt is made to write a value
- to that variable. It then sets the read-only variable PI and sets up
- a write trace on it (why do I do this by hand; why not just send
- myself a "setReadOnly:" msg? Also, I should have a specific read
- trace, so if people haven't made it global, and try to read it it will
- get a value... will this fuck things with closure? Who cares if
- 3.14xxx gets put in? )
-
- When a WWEveParser gets init'ed, it allocs up a WWInterp and does a
- few more things.
-
- First it set the value of "scene(incr)" and then it sets up two
- traces; a read and a write trace.
-
- When the WW3DWell inits, it hooks the eveParser up with the
- sceneClock, it sets the value of "scene(ticksPerSecond)" to a read
- only value. (One problem here - every time you set a value to
- read-only, it initiates a new trace on it. This is wicked
- wasteful...) ((Does this still happen?))
-
- So now we have "PI", "scene(ticksPerSecond)", and "scene(incr)" all
- being traced, the first two for read and last for read and write.
-
- Now we drop a .wwModel into the well. For each EveCmd in the model
- file, we perform a "closure" on the expression that the EveCmd is
- based on. That closure is performed by the EveCmd's eveParser which
- returns a WWTCLClosedCmd object. That object has within it a set of
- traces which have been set up in the parser. Let's look at how those
- got instantiated.
-
- The EveCommand hands the expression (as a string) to the eveParser and
- asks it to generate a closure. The eveParser hands it to the tcl
- interp object. For each global variable it finds in the expression,
- the interp sends a msg to itself adding a write trace on the variable
- using clientData, and then it sends a addTraceFor:calling:using: msg
- to the new closed cmd that it's building up. One weird thing about
- this is that both the interp and the closed cmd *each* have a
- WWTCLVarTrace object corresponding to this trace. This is potentially
- troubling, because if they both ask to be deleted, we could have
- trouble. Do they? What happens when an EveCommand gets free'ed?
-
- Well, when the EveCommand gets free'ed, it free's its closed command,
- cmd. It frees its list of traces. Each of those traces, when
- free'ed, removes itself from the WWTCLInterp's list of traces.
-
-